<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自定义Message组件示例</title>
    <link rel="stylesheet" href="../resources/css/calling/component/custom-message.css">
    <style>
        body {
            font-family: Arial, sans-serif;
            padding: 20px;
            max-width: 800px;
            margin: 0 auto;
        }
        h1 {
            color: #409EFF;
            text-align: center;
            margin-bottom: 30px;
        }
        .demo-section {
            margin-bottom: 30px;
            padding: 20px;
            border: 1px solid #EBEEF5;
            border-radius: 4px;
        }
        h2 {
            margin-top: 0;
            color: #606266;
            font-size: 18px;
            margin-bottom: 15px;
        }
        .button-group {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
        }
        button {
            padding: 8px 15px;
            border-radius: 4px;
            border: 1px solid #DCDFE6;
            background-color: #fff;
            cursor: pointer;
            transition: all 0.3s;
            font-size: 14px;
        }
        button:hover {
            color: #409EFF;
            border-color: #c6e2ff;
            background-color: #ecf5ff;
        }
        button.primary {
            color: #fff;
            background-color: #409EFF;
            border-color: #409EFF;
        }
        button.primary:hover {
            background-color: #66b1ff;
            border-color: #66b1ff;
            color: #fff;
        }
        button.success {
            color: #fff;
            background-color: #67C23A;
            border-color: #67C23A;
        }
        button.success:hover {
            background-color: #85ce61;
            border-color: #85ce61;
        }
        button.warning {
            color: #fff;
            background-color: #E6A23C;
            border-color: #E6A23C;
        }
        button.warning:hover {
            background-color: #ebb563;
            border-color: #ebb563;
        }
        button.danger {
            color: #fff;
            background-color: #F56C6C;
            border-color: #F56C6C;
        }
        button.danger:hover {
            background-color: #f78989;
            border-color: #f78989;
        }
        button.info {
            color: #fff;
            background-color: #909399;
            border-color: #909399;
        }
        button.info:hover {
            background-color: #a6a9ad;
            border-color: #a6a9ad;
        }
        .code-block {
            background-color: #f5f7fa;
            padding: 15px;
            border-radius: 4px;
            margin-top: 15px;
            font-family: monospace;
            white-space: pre-wrap;
            font-size: 14px;
            color: #303133;
        }
        .form-group {
            margin-bottom: 15px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
            color: #606266;
        }
        input, select {
            width: 100%;
            padding: 8px;
            border-radius: 4px;
            border: 1px solid #DCDFE6;
            box-sizing: border-box;
        }
    </style>
</head>
<body>
    <h1>自定义Message组件示例</h1>
    
    <div class="demo-section">
        <h2>基础用法</h2>
        <div class="button-group">
            <button onclick="showBasicMessage()">显示消息</button>
        </div>
        <div class="code-block">CustomMessage.message('这是一条消息提示');</div>
    </div>
    
    <div class="demo-section">
        <h2>不同类型</h2>
        <div class="button-group">
            <button class="success" onclick="showSuccessMessage()">成功</button>
            <button class="warning" onclick="showWarningMessage()">警告</button>
            <button class="danger" onclick="showErrorMessage()">错误</button>
            <button class="info" onclick="showInfoMessage()">信息</button>
        </div>
        <div class="code-block">CustomMessage.success('这是一条成功消息');
CustomMessage.warning('这是一条警告消息');
CustomMessage.error('这是一条错误消息');
CustomMessage.info('这是一条信息消息');</div>
    </div>
    
    <div class="demo-section">
        <h2>可关闭的消息</h2>
        <div class="button-group">
            <button onclick="showClosableMessage()">显示可关闭消息</button>
        </div>
        <div class="code-block">CustomMessage.message({
    message: '这是一条可关闭的消息',
    showClose: true
});</div>
    </div>
    
    <div class="demo-section">
        <h2>自定义显示时间</h2>
        <div class="button-group">
            <button onclick="showCustomDurationMessage()">显示10秒后关闭</button>
            <button onclick="showNeverCloseMessage()">永不关闭</button>
        </div>
        <div class="code-block">// 显示10秒后关闭
CustomMessage.message({
    message: '这条消息10秒后关闭',
    duration: 10000
});

// 永不关闭
CustomMessage.message({
    message: '这条消息不会自动关闭',
    duration: 0,
    showClose: true
});</div>
    </div>
    
    <div class="demo-section">
        <h2>使用HTML片段</h2>
        <div class="button-group">
            <button onclick="showHTMLMessage()">显示HTML内容</button>
            <button onclick="showRichHTMLMessage()">显示富文本内容</button>
            <button onclick="showLinkMessage()">显示链接内容</button>
        </div>
        <div class="code-block">// 基础HTML内容
CustomMessage.info('&lt;strong&gt;这是 &lt;i style="color: teal"&gt;HTML&lt;/i&gt; 片段&lt;/strong&gt;');

// 富文本内容
CustomMessage.success('&lt;div style="text-align: center;"&gt;&lt;h4 style="margin: 0; color: #67C23A;"&gt;操作成功！&lt;/h4&gt;&lt;p style="margin: 5px 0 0 0; font-size: 12px;"&gt;数据已保存&lt;/p&gt;&lt;/div&gt;');

// 包含链接的内容
CustomMessage.warning('请查看 &lt;a href="#" style="color: #E6A23C; text-decoration: underline;"&gt;详细说明&lt;/a&gt; 了解更多信息');</div>
    </div>
    
    <div class="demo-section">
        <h2>关闭所有消息</h2>
        <div class="button-group">
            <button class="primary" onclick="closeAllMessages()">关闭所有消息</button>
        </div>
        <div class="code-block">CustomMessage.closeAll();</div>
    </div>
    
    <div class="demo-section">
        <h2>自定义消息</h2>
        <form id="customMessageForm">
            <div class="form-group">
                <label for="messageType">消息类型</label>
                <select id="messageType">
                    <option value="info">信息</option>
                    <option value="success">成功</option>
                    <option value="warning">警告</option>
                    <option value="error">错误</option>
                </select>
            </div>
            <div class="form-group">
                <label for="messageContent">消息内容</label>
                <input type="text" id="messageContent" value="自定义消息内容" />
            </div>
            <div class="form-group">
                <label for="messageDuration">显示时间 (毫秒，0表示不自动关闭)</label>
                <input type="number" id="messageDuration" value="3000" min="0" step="1000" />
            </div>
            <div class="form-group">
                <label style="display: flex; align-items: center;">
                    <input type="checkbox" id="showCloseBtn" style="width: 50px;" /> 显示关闭按钮
                </label>
            </div>
            <div class="button-group">
                <button type="button" class="primary" onclick="showCustomMessage()">显示自定义消息</button>
            </div>
        </form>
    </div>

    <script src="../resources/js/custom-message.js"></script>
    <script>
        // 基础消息
        function showBasicMessage() {
            CustomMessage.message('这是一条消息提示');
        }
        
        // 成功消息
        function showSuccessMessage() {
            CustomMessage.success('这是一条成功消息');
        }
        
        // 警告消息
        function showWarningMessage() {
            CustomMessage.warning('这是一条警告消息');
        }
        
        // 错误消息
        function showErrorMessage() {
            CustomMessage.error('这是一条错误消息');
        }
        
        // 信息消息
        function showInfoMessage() {
            CustomMessage.info('这是一条信息消息');
        }
        
        // 可关闭的消息
        function showClosableMessage() {
            CustomMessage.message({
                message: '这是一条可关闭的消息',
                showClose: true
            });
        }
        
        // 自定义显示时间
        function showCustomDurationMessage() {
            CustomMessage.message({
                message: '这条消息10秒后关闭',
                duration: 10000
            });
        }
        
        // 永不关闭
        function showNeverCloseMessage() {
            CustomMessage.message({
                message: '这条消息不会自动关闭',
                duration: 0,
                showClose: true
            });
        }
        
        // HTML内容
        function showHTMLMessage() {
            CustomMessage.info('<strong>这是 <i style="color: teal">HTML</i> 片段</strong>');
        }
        
        // 富文本内容
        function showRichHTMLMessage() {
            CustomMessage.success('<div style="text-align: center;"><h4 style="margin: 0; color: #67C23A;">操作成功！</h4><p style="margin: 5px 0 0 0; font-size: 12px;">数据已保存</p></div>');
        }
        
        // 包含链接的内容
        function showLinkMessage() {
            CustomMessage.warning('请查看 <a href="#" style="color: #E6A23C; text-decoration: underline;" onclick="alert(\'点击了链接\'); return false;">详细说明</a> 了解更多信息');
        }
        
        // 关闭所有消息
        function closeAllMessages() {
            CustomMessage.closeAll();
        }
        
        // 自定义消息
        function showCustomMessage() {
            const type = document.getElementById('messageType').value;
            const content = document.getElementById('messageContent').value;
            const duration = parseInt(document.getElementById('messageDuration').value);
            const showClose = document.getElementById('showCloseBtn').checked;
            
            const options = {
                message: content,
                duration: duration,
                showClose: showClose
            };
            
            switch(type) {
                case 'success':
                    CustomMessage.success(content, { duration: duration, showClose: showClose });
                    break;
                case 'warning':
                    CustomMessage.warning(content, { duration: duration, showClose: showClose });
                    break;
                case 'error':
                    CustomMessage.error(content, { duration: duration, showClose: showClose });
                    break;
                case 'info':
                default:
                    CustomMessage.info(content, { duration: duration, showClose: showClose });
                    break;
            }
        }
    </script>
</body>
</html>